package Servlet.StudentServlet;

import Entity.Student;
import Service.StudentService.StudentService;
import javafx.scene.chart.ValueAxis;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import java.io.IOException;
import java.io.PrintWriter;
/*
负责学生 注册 数据接口
 */
@WebServlet(value = "/studentRegister")
public class StudentRegister extends javax.servlet.http.HttpServlet {
    private  StudentService studentService = new StudentService();

    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");

        String studentId = request.getParameter("studentId");
        String studentPassword = request.getParameter("studentPassword");
        String studentName = request.getParameter("studentName");
        String studentMajor = request.getParameter("studentMajor");


        Student student =new Student();
        student.setStudentId(studentId);
        student.setStudentPassword(studentPassword);
        student.setStudentName(studentName);
        student.setStudentMajor(studentMajor);


        PrintWriter out = response.getWriter();

        int status = studentService.studentRegister(student);
        out.print(status);


        out.close();

    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        doPost(request,response);
    }
}
